function trim(input) {
    return input && typeof input === 'string' ? input.trim() : input;
}

function lowerCase(input) {
    return input && typeof input === "string" ? input.toLowerCase() : input;
}

function split(input, delimiter = ",") {
    return typeof input === "string" ? input.split(delimiter) : input;
}

function compose(...funcs) {
    return function(x){
        return funcs.reduce(function(arg, fn){
            return fn(arg)
        }, x)
    }
}

const trimLowercaseAndSplit = compose(trim, lowerCase, split);
let result = trimLowercaseAndSplit(" a,B,c")
console.log(result)



function add(a){
    return function(b){
        return a+b
    }
}

const addNext = add(1)

 setTimeout(()=>{
    let sum = addNext(2)
    console.log(sum)
}, 1000)
